<?php
/**
 * @Notes:【】
 * @Date: 2022-06-05 17:52
 */

namespace App\Controller\Tasker\Task;

use App\Controller\Task\BaseController;
use App\Dao\Task\TaskDao;
use App\Dao\User\WechatUserDao;
use App\Dao\Users\UsersDao;
use App\Middleware\AuthTokenMiddleware;
use App\Middleware\CheckLoginMiddleware;
use App\Service\Order\PayService;
use App\Service\Pay\PayFactory;
use App\Service\Task\TaskService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;


/**
 * @Notes:【】
 * @Date: 2022-06-05 17:52
 * @ApiController(prefix="tasker/task/pay")
 * @Middleware(AuthTokenMiddleware::class)
 */
class PayController extends BaseController
{
    /**
     * @Inject()
     * @var TaskService
     */
    protected $taskService;

    /**
     * @Inject()
     * @var PayService
     */
    protected $payService;

    /**
     * @Notes:【】
     * @Date: 2022-06-05 17:54
     * @PostApi(path="task")
     * @FormData(key="task_id")
     * @FormData(key="paytype",default="weixin")
     */
    public function task()
    {
        $usersId = $this->getUid();
        $task_id = $this->getValidatorData('task_id');
        $type = $this->getValidatorData('paytype');
        $url = $this->payService->task($usersId, $task_id, $type);
        succ($url);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-12 14:05
     * @PostApi(path="refresh")
     * @FormData(key="refresh_id")
     */
    public function refresh()
    {
        $usersId = $this->getUid();
        $refresh_id = $this->getValidatorData('refresh_id');
        $url = $this->payService->settles($usersId, $refresh_id);
        succ($url);
    }

    /**
     * @Notes:【】
     * @Date: 2022-06-12 14:05
     * @PostApi(path="top")
     * @FormData(key="top_id")
     */
    public function top()
    {
        $usersId = $this->getUid();
        $top_id = $this->getValidatorData('top_id');
        $url = $this->payService->settlesTop($usersId, $top_id);
        succ($url);
    }

}